<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller{
	function index(){
		$this->display();
	}
	function check(){
		$verify=new \Think\Verify();
		 if(!$verify->check($_POST['verify'])){
		 	$this->error("验证码错误",U("Admin/Login/index"));
		 	exit();
		 }
	    $admin=new \Think\Model('manager');
		//接收表单数据
		$username=$_POST['username'];
		$password=$_POST['password'];
		//查询
		$re=$admin->where("username='%s' and password='%s'",array($username,$password))
			  	  ->find();
		//判断 如果有 创建会话变量 跳转后台首页
		if($re){
			$_SESSION['manager_id']=$re['id'];
			$_SESSION['manager_username']=$username;
			$this->redirect("Admin/Index/index");
		}else{
			//否则提示错误，跳转到登录
			$this->redirect("Admin/Login/index");
		}
	}
}
